package com.jiyun.service;

import com.jiyun.entity.Goods;
import com.jiyun.entity.GoodsType;
import com.jiyun.entity.GoodsVo;
import com.jiyun.mapper.GoodsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsService {

    @Autowired
    GoodsMapper goodsMapper;

    public List<GoodsVo> findAll() {
        return goodsMapper.findAll();
    }

    public List<GoodsType> findGoodsType() {
        return goodsMapper.findGoodsType();
    }

    public void addGoods(Goods goods) {
        goodsMapper.insert(goods);
    }

    public void deleteGoods(Integer id) {
        goodsMapper.deleteByPrimaryKey(id);
    }

    public Goods findGoodsById(Integer id) {
        return goodsMapper.selectByPrimaryKey(id);
    }

    public void updateGoods(Goods goods) {
        goodsMapper.updateByPrimaryKeySelective(goods);
    }
}
